home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / disk / cdrom / MusicBox-2.1os.lha / MusicBox / MusicBox.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-29  |  35.2 KB  |  1,640 lines

  1. /*
  2.  ##########################################################################
  3.  ####                                                                  ####
  4.  ####                        The MusicBox Project                      ####
  5.  ####                    ============================                  ####
  6.  ####                                                                  ####
  7.  #### MusicBox.c                                                       ####
  8.  ####                                                                  ####
  9.  #### Version 2.1os  --  September 29, 2000                            ####
  10.  ####                                                                  ####
  11.  #### Copyright (C) 1994  Thomas Dreibholz                             ####
  12.  ####               2000  Molbachweg 7                                 ####
  13.  ####                     51674 Wiehl                                  ####
  14.  ####                     Germany                                      ####
  15.  ####                                                                  ####
  16.  ####                     EMail: Dreibholz@bigfoot.com                 ####
  17.  ####                     WWW:   http://www.bigfoot.com/~dreibholz     ####
  18.  ####                                                                  ####
  19.  ##########################################################################
  20. */
  21. /***************************************************************************
  22.  *                                                                         *
  23.  *   This program is free software; you can redistribute it and/or modify  *
  24.  *   it under the terms of the GNU General Public License as published by  *
  25.  *   the Free Software Foundation; either version 2 of the License, or     *
  26.  *   (at your option) any later version.                                   *
  27.  *                                                                         *
  28.  ***************************************************************************/
  29.  
  30. /* MusicBox Hauptprogramm */
  31.  
  32. #include "MusicBox.h"
  33. #include "MusicBoxLibrary.h"
  34.  
  35. void TesteLaufwerk();
  36. void Iconify();
  37. void ZeigeNum();
  38. void Num();
  39. void IntuiTicks();
  40. void Fill();
  41.  
  42. struct Einstellungen Einstellungen=
  43. {
  44.  0,
  45.  0L,
  46.  255,255,
  47.  AUDIO_LINKS,
  48.  AUDIO_RECHTS,
  49.  0,
  50.  0,DATEN,0,
  51.  0,STANDBY,JOYSTICK_II,
  52.  01,
  53.  0,ZEIT_TICKS,0,0,255,0,0,0,0,0,
  54.  1,1,1,1,0,0,0
  55. };
  56.  
  57. UBYTE *VerStr=VERSTR;
  58. UBYTE  DeviceName[40];
  59. LONG   UnitNumber=-1L;
  60. UBYTE  ARexxName[40];
  61.  
  62. struct Library         *GfxBase;
  63. extern struct Library  *IconBase;
  64. extern struct ExecBase *SysBase;
  65. struct Library         *WorkbenchBase;
  66. struct Library         *DiskfontBase;
  67. struct IntuitionBase   *IntuitionBase;
  68. struct Library         *GadToolsBase;
  69. struct Library         *LocaleBase;
  70. struct Library         *MusicBoxBase;
  71. struct Library         *TimerBase;
  72. struct Library         *AmigaGuideBase;
  73.  
  74. extern int SetupScreen();
  75. extern int OpenCDPlayerWindow();
  76.  
  77. extern struct Gadget     *CDPlayerGadgets[27];
  78. extern struct Window     *CDPlayerWnd;
  79. extern struct ThisCD     *ThisCD;
  80. extern struct ThisDrive  *ThisDrive;
  81. extern struct TextFont   *Font;
  82. extern struct List        Liste;
  83. extern struct DiskObject  AudioCD;
  84. extern struct DiskObject  CDMusicBox;
  85. extern struct VisualInfo *VisualInfo;
  86. extern struct WBenchMsg  *WBenchMsg;
  87.  
  88. struct Katalog           *Katalog;
  89. struct Locale            *Locale;
  90. struct Catalog           *Catalog;
  91.  
  92. BOOL WarteAufAudio=FALSE;
  93. BOOL IstDatenCD=FALSE;
  94. BOOL IsIconify=FALSE;
  95. BOOL DivLevel=FALSE;
  96.  
  97. BOOL Quiet=FALSE;
  98. BOOL USModus=FALSE;
  99. BOOL LowRes=FALSE;
  100. BOOL NoReq=FALSE;
  101. BOOL NoTT=FALSE;
  102. BOOL FastExit=FALSE;
  103.  
  104. int   ox,oy;
  105. LONG  ProcessSignal=-1L;
  106. ULONG IDCMPSignalMask,
  107.       AppSignalMask,
  108.       ProcessSignalMask,
  109.       ControlSignalMask,
  110.       ARexxSignalMask;
  111. ULONG WaitSignalMask;
  112.  
  113.  
  114. struct TextAttr DisplayAttr={"hifi-display.font",18,FS_NORMAL,FPF_DISKFONT};
  115. struct TextAttr SmallAttr={"hifi-display.font",7,FS_NORMAL,FPF_DISKFONT};
  116. struct TextAttr TimesAttr={"times.font",18,FS_NORMAL,FPF_DISKFONT};
  117.  
  118. struct TextFont    *DisplayFont;
  119. struct TextFont    *SmallFont;
  120. struct TextFont    *TimesFont;
  121. struct RastPort    *RPort;
  122. struct MsgPort     *AppPort;
  123. struct MsgPort     *ControlPort;
  124. struct MsgPort     *ARexxPort;
  125. struct AppIcon     *AppIcon;
  126. struct AppMenuItem *AppItem;
  127. struct AppMessage  *AppMsg;
  128.  
  129. void PutText(x,y,text)
  130.  int     x,y;
  131.  UBYTE *text;
  132. {
  133. /*
  134.  Move(RPort,x+ox,y+oy);
  135.  Text(RPort,text,strlen(text));
  136. */
  137.  PutTextA(CDPlayerWnd,x,y,text);
  138. }
  139.  
  140. UBYTE *GS(num,def)
  141.  LONG   num;
  142.  UBYTE *def;
  143. {
  144.  if(Catalog==NULL) return(def);
  145.  return(GetCatalogStr(Catalog,num,def));
  146. }
  147.  
  148. void ZeigeVolumen()
  149. {
  150.  UBYTE text[6];
  151.  
  152.  if(IsIconify) return;
  153.  
  154.  SetAPen(RPort,FARBE);
  155.  SetFont(RPort,SmallFont);
  156.  sprintf(&text,"A%3d",Einstellungen.VolumenL);
  157.  PutText(14+(13*22),25,&text);
  158.  sprintf(&text,"B%3d",Einstellungen.VolumenR);
  159.  PutText(14+(13*22),34,&text);
  160.  SetFont(RPort,DisplayFont);
  161. }
  162.  
  163. void ZeigeLR()
  164. {
  165.  UBYTE text[2];
  166.  
  167.  if(IsIconify) return;
  168.  
  169.  text[1]=0x00;
  170.  if(Einstellungen.AudioL!=0) SetAPen(RPort,FARBE); else SetAPen(RPort,0);
  171.  text[0]=Einstellungen.AudioL+((UBYTE)'!'-1);
  172.  PutText(5+(12*22)-5,35,&text);
  173.  if(Einstellungen.AudioR!=0) SetAPen(RPort,FARBE); else SetAPen(RPort,0);
  174.  text[0]=Einstellungen.AudioR+(UBYTE)'#';
  175.  PutText(5+(16*22),35,&text);
  176.  
  177.  SetzeLR();
  178. }
  179.  
  180. void ZeigeCDInfo()
  181. {
  182.  if(IsIconify) return;
  183.  
  184.  if(Einstellungen.AutoStart!=0) SetAPen(RPort,FARBE); else SetAPen(RPort,0);
  185.  PutText(5+(4*22),35,"*");
  186.  if(Einstellungen.AutoRepeat!=0) SetAPen(RPort,FARBE); else SetAPen(RPort,0);
  187.  PutText(5+(5*22),35,")");
  188.  
  189.  SetAPen(RPort,FARBE);
  190.  if(Einstellungen.Lock)
  191.    PutText(5+(6*22),35,"]");
  192.  else
  193.    PutText(5+(6*22),35,"(");
  194.  if(Einstellungen.CDEingelegt)
  195.   {
  196.    PutText(5+(7*22),35,"R");
  197.    switch(Einstellungen.CDTyp)
  198.     {
  199.      case DATEN:
  200.        PutText(5+(8*22),35,"X");
  201.       break;
  202.      case AUDIO:
  203.        PutText(5+(8*22),35,"Y");
  204.       break;
  205.     }
  206.    switch(Einstellungen.CDTyp)
  207.     {
  208.      case DATEN:
  209.        PutText(5+(8*22),35,"X");
  210.       break;
  211.      case AUDIO:
  212.        PutText(5+(8*22),35,"Y");
  213.       break;
  214.     }
  215.    if(Einstellungen.CDKatalogisiert)
  216.      PutText(5+(9*22),35,"[");
  217.    else
  218.      PutText(5+(9*22),35,"P");
  219.   }
  220.  else
  221.   {
  222.    PutText(5+(7*22),35,"Q  ");
  223.   }
  224. }
  225.  
  226. void ZeigeTrackDisplay()
  227. {
  228.  REGISTER ULONG   adr,prozent;
  229.  REGISTER UBYTE   frame,track,min,sek;
  230.  UWORD            i,j;
  231.  UBYTE            text[80],zeichen;
  232.  struct DateStamp ds;
  233.  struct TagItem   tag[3];
  234.  
  235.  if(!(Einstellungen.Funktion==POSITION)) LeseStatus();
  236.  if(IsIconify) return;
  237.  
  238.  if(Einstellungen.Adresse>ThisCD->Endadresse)
  239.    Einstellungen.Adresse=ThisCD->Endadresse;
  240.  if(Einstellungen.Adresse<ThisCD->Startadresse)
  241.    Einstellungen.Adresse=ThisCD->Startadresse;
  242.  
  243.  tag[0].ti_Tag=GTSL_Max;
  244.  tag[1].ti_Tag=GTSL_Level;
  245.  tag[2].ti_Tag=TAG_DONE;
  246.  
  247.  SetAPen(RPort,FARBE);
  248.  if(Einstellungen.Funktion!=STANDBY)
  249.   {
  250.    tag[0].ti_Data=ThisCD->Track[Einstellungen.Track-1].TAdresse-225;
  251.    tag[1].ti_Data=Einstellungen.Adresse-
  252.                   ThisCD->Track[Einstellungen.Track-1].SAdresse;
  253.    if(tag[0].ti_Data>32000)
  254.     {
  255.      DivLevel=TRUE;
  256.      tag[0].ti_Data/=2;
  257.      tag[1].ti_Data/=2;
  258.     }
  259.    else DivLevel=FALSE;
  260.    if(tag[1].ti_Data>tag[0].ti_Data) tag[1].ti_Data=tag[0].ti_Data;
  261.    switch(Einstellungen.Anzeige)
  262.     {
  263.      case TRACK_ANFANG:
  264.        track=Einstellungen.Track;
  265.        adr=Einstellungen.Adresse-ThisCD->Track[Einstellungen.Track-1].SAdresse;
  266.        prozent=(1000*adr)/ThisCD->Track[Einstellungen.Track-1].TAdresse;
  267.        zeichen='l';
  268.       break;
  269.      case TRACK_ENDE:
  270.        adr=ThisCD->Track[Einstellungen.Track-1].TAdresse+
  271.            ThisCD->Track[Einstellungen.Track-1].SAdresse-
  272.            Einstellungen.Adresse;
  273.        prozent=(1000*adr)/ThisCD->Track[Einstellungen.Track-1].TAdresse;
  274.        zeichen='m';
  275.       break;
  276.      case CD_ANFANG:
  277.        adr=Einstellungen.Adresse;
  278.        prozent=(1000*adr)/ThisCD->Endadresse;
  279.        zeichen='n';
  280.       break;
  281.      case CD_ENDE:
  282.        adr=ThisCD->Endadresse-Einstellungen.Adresse;
  283.        prozent=(1000*adr)/ThisCD->Endadresse;
  284.        zeichen='o';
  285.       break;
  286.     }
  287.  
  288.    min=(adr/75/60);
  289.    sek=((adr/75) % 60);
  290.    frame=(adr % 75);
  291.  
  292.    if(Einstellungen.Format==ZEIT)
  293.     {
  294.      if(Einstellungen.Funktion==WIEDERGABE)
  295.       {
  296.        sprintf(&text,"%02d %c%02d:%02d  ^  ",
  297.                Einstellungen.Track,
  298.                zeichen,
  299.                min,
  300.                sek);
  301.       }
  302.      else
  303.       {
  304.        sprintf(&text,"%02d %c%02d:%02d  ^%02d",
  305.                Einstellungen.Track,
  306.                zeichen,
  307.                min,
  308.                sek,
  309.                frame);
  310.       }
  311.     }
  312.    else if(Einstellungen.Format==ADRESSE)
  313.     {
  314.      zeichen+=4;
  315.      sprintf(&text,"%02d %c %05lx",
  316.              Einstellungen.Track,
  317.              zeichen,
  318.              adr);
  319.     }
  320.    else if(Einstellungen.Format==MEGABYTES)
  321.     {
  322.      zeichen+=12;
  323.      sprintf(&text,"%02d %c%4ld.%ld",
  324.              Einstellungen.Track,
  325.              zeichen,
  326.              adr/512,(adr % 512)/52);
  327.     }
  328.    else
  329.     {
  330.      zeichen+=8;
  331.      sprintf(&text,"%02d %c%3ld.%ld",
  332.              Einstellungen.Track,
  333.              zeichen,
  334.              prozent/10,
  335.              prozent % 10);
  336.     }
  337.   }
  338.  else
  339.   {
  340.    tag[0].ti_Data=0;
  341.    tag[1].ti_Data=0;
  342.    DateStamp(&ds);
  343.    sprintf(&text,"-- S%2d:%02d T%02d",
  344.            ds.ds_Minute/60,
  345.            ds.ds_Minute % 60,
  346.            ds.ds_Tick / 50);
  347.   }
  348.  j=strlen(&text);
  349.  if(j<14)
  350.    for(i=j;i<15;i++) strcat(&text," ");
  351.  PutText(5+22,10,&text);
  352.  GTSetGadgetAttrsA(CDPlayerGadgets[27],CDPlayerWnd,NULL,&tag);
  353.  
  354.  if(Einstellungen.Titel!=Einstellungen.Track)
  355.   {
  356.    Einstellungen.Titel=Einstellungen.Track;
  357.    if(Einstellungen.CDEingelegt)
  358.     {
  359.      WarteAufAudio=FALSE;
  360.      if(Einstellungen.CDTyp==AUDIO)
  361.       {
  362.        IstDatenCD=FALSE;
  363.        sprintf(&text,"%s    (%d:%02d '%02d)",
  364.                &Katalog->KE[Einstellungen.Track-1].Titel,
  365.                ThisCD->Track[Einstellungen.Track-1].TMinute,
  366.                ThisCD->Track[Einstellungen.Track-1].TSekunde,
  367.                ThisCD->Track[Einstellungen.Track-1].TFrame);
  368.        SetFont(RPort,TimesFont);
  369.        Fill();
  370.        if(LowRes==TRUE)
  371.         {
  372.          PutMText(CDPlayerWnd,11,152,&Katalog->CDName,430);
  373.          PutMText(CDPlayerWnd,11,171,&text,570);
  374.         }
  375.        else
  376.         {
  377.          PutMText(CDPlayerWnd,11,196,&Katalog->CDName,430);
  378.          PutMText(CDPlayerWnd,11,215,&text,570);
  379.         }
  380.       }
  381.      else
  382.       {
  383.        if(IstDatenCD==FALSE)
  384.         {
  385.          SetFont(RPort,TimesFont);
  386.          Fill();
  387.          if(LowRes==FALSE)
  388.            PutText(11,205,GS(39,"-- The inserted disc is a data CD --"));
  389.          else
  390.            PutText(11,160,GS(39,"-- The inserted disc is a data CD --"));
  391.          IstDatenCD=TRUE;
  392.         }
  393.       }
  394.     }
  395.    else
  396.     {
  397.      IstDatenCD=FALSE;
  398.      if(WarteAufAudio==FALSE)
  399.       {
  400.        SetFont(RPort,TimesFont);
  401.        Fill();
  402.        if(LowRes==FALSE)
  403.          PutText(11,205,GS(40,"-- Please insert an audio CD --"));
  404.        else
  405.          PutText(11,160,GS(40,"-- Please insert an audio CD --"));
  406.        WarteAufAudio=TRUE;
  407.       }
  408.     }
  409.    SetFont(RPort,DisplayFont);
  410.    if(LowRes==FALSE)
  411.      PutText(600,220,"?");
  412.    else
  413.      PutText(600,174,"?");
  414.   }
  415. }
  416.  
  417. void Fill()
  418. {
  419.  SetAPen(RPort,0);
  420.  if(LowRes==FALSE)
  421.   {
  422.    RectFill(RPort,ox + 0, oy + 183, ox+465, oy+221);
  423.    RectFill(RPort,ox + 466, oy + 203, ox+621, oy+221);
  424.   }
  425.  else
  426.   {
  427.    RectFill(RPort,ox + 0, oy + 139, ox+465, oy+175);
  428.    RectFill(RPort,ox + 466, oy + 155, ox+621, oy+175);
  429.   }
  430.  SetAPen(RPort,FARBE);
  431. }
  432.  
  433. void Symbol(num)
  434.  UBYTE num;
  435. {
  436.  if(IsIconify) return;
  437.  
  438.  SetAPen(RPort,FARBE);
  439.  switch(num)
  440.   {
  441.    case WIEDERGABE:
  442.      PutText(5,35,"<");
  443.     break;
  444.    case STOP:
  445.      PutText(5,35,";");
  446.     break;
  447.    case PAUSE:
  448.      PutText(5,35,"=");
  449.     break;
  450.    case STANDBY:
  451.      PutText(5,35,">");
  452.     break;
  453.    case VORLAUF:
  454.      PutText(5,35,"h");
  455.     break;
  456.    case RUECKLAUF:
  457.      PutText(5,35,"g");
  458.     break;
  459.    case PLUS:
  460.      PutText(5,35,"i");
  461.     break;
  462.    case MINUS:
  463.      PutText(5,35,"j");
  464.     break;
  465.    case AUTO:
  466.      PutText(5,35,"U");
  467.     break;
  468.    case POSITION:
  469.      PutText(5,35,"+");
  470.     break;
  471.   }
  472.  
  473. }
  474.  
  475. void ZeigeStatus()
  476. {
  477.  if(IsIconify) return;
  478.  
  479.  if((Einstellungen.Funktion==VORLAUF)||(Einstellungen.Funktion==RUECKLAUF))
  480.    Einstellungen.TickCnt=1;
  481.  else if(Einstellungen.Funktion==STANDBY)
  482.    Einstellungen.TickCnt=8;
  483.  else
  484.    if(Einstellungen.Format==ADRESSE)
  485.      Einstellungen.TickCnt=ADRESSE_TICKS;
  486.    else
  487.      Einstellungen.TickCnt=ZEIT_TICKS;
  488.  
  489.  Symbol(Einstellungen.Funktion);
  490.  
  491.  switch(Einstellungen.SCSI)
  492.   {
  493.    case 1:
  494.      PutText(5+22,35,"V");
  495.     break;
  496.    case 0:
  497.      PutText(5+22,35,"\\");
  498.     break;
  499.    case 2:
  500.      PutText(5+22,35,"k");
  501.     break;
  502.   }
  503.  
  504.  switch(Einstellungen.Kontrolle)
  505.   {
  506.    case AUS:
  507.      PutText(5+(2*22),35,"M");
  508.     break;
  509.    case JOYSTICK_I:
  510.      PutText(5+(2*22),35,"J");
  511.     break;
  512.    case JOYSTICK_II:
  513.      PutText(5+(2*22),35,"K");
  514.     break;
  515.   }
  516.  
  517.  ZeigeTrackDisplay();
  518.  ZeigeNum();
  519. }
  520.  
  521. void CDDisplay()
  522. {
  523.  if(IsIconify) return;
  524.  
  525.  SetAPen(RPort,FARBE);
  526.  SetFont(RPort,DisplayFont);
  527.  
  528.  ZeigeStatus();
  529.  ZeigeCDInfo();
  530.  ZeigeLR();
  531.  ZeigeVolumen();
  532.  
  533.  PutText(5,10,"`");
  534.  if(Einstellungen.Toshiba) PutText(5+(16*22),10,"_");
  535.  if(LowRes==FALSE)
  536.    PutText(600,220,"?");
  537.  else
  538.    PutText(600,174,"?");
  539. }
  540.  
  541.  
  542. void CloseAll()
  543. {
  544.  CloseCDPlayerWindow();
  545.  CloseDownScreen();
  546.  EntferneProzess();
  547.  if(TimesFont)
  548.   {
  549.    if(Einstellungen.AutoFlush) RemFont(TimesFont);
  550.    CloseFont(TimesFont);
  551.   }
  552.  if(DisplayFont)
  553.   {
  554.   if(Einstellungen.AutoFlush) RemFont(DisplayFont);
  555.    CloseFont(DisplayFont);
  556.   }
  557.  if(SmallFont)
  558.   {
  559.    if(Einstellungen.AutoFlush) RemFont(SmallFont);
  560.    CloseFont(SmallFont);
  561.   }
  562.  EntferneSCSI();
  563.  EntferneIcon();
  564.  if(Katalog) FreeMem(Katalog,sizeof(struct Katalog));
  565.  if(ARexxPort) DeletePortA(ARexxPort);
  566.  if(AppPort) DeletePortA(AppPort);
  567.  if(ControlPort) DeleteMMPort(ControlPort);
  568.  if(ProcessSignal!=-1L) FreeSignal(ProcessSignal);
  569.  if(TimerBase)
  570.   {
  571.    Forbid();
  572.    TimerBase->lib_OpenCnt--;
  573.    Permit();
  574.   }
  575.  if(MusicBoxBase)
  576.   {
  577.    if(Einstellungen.AutoFlush)
  578.      KillLibrary(MusicBoxBase);
  579.    else
  580.      CloseLibrary(MusicBoxBase);
  581.   }
  582.  if(GfxBase) CloseLibrary(GfxBase);
  583.  if(IntuitionBase) CloseLibrary(IntuitionBase);
  584.  if(IconBase) CloseLibrary(IconBase);
  585.  if(LocaleBase)
  586.   {
  587.    if(Catalog) CloseCatalog(Catalog);
  588.    if(Locale) CloseLocale(Locale);
  589.    CloseLibrary(LocaleBase);
  590.   }
  591.  if(WorkbenchBase) CloseLibrary(WorkbenchBase);
  592.  if(DiskfontBase)
  593.   {
  594.    if(Einstellungen.AutoFlush)
  595.      KillLibrary(DiskfontBase);
  596.    else
  597.      CloseLibrary(DiskfontBase);
  598.   }
  599.  if(AmigaGuideBase)
  600.   {
  601.    if(Einstellungen.AutoFlush)
  602.      KillLibrary(AmigaGuideBase);
  603.    else
  604.      CloseLibrary(AmigaGuideBase);
  605.   }
  606.  if(GadToolsBase) CloseLibrary(GadToolsBase);
  607.  exit(0);
  608. }
  609.  
  610. void OpenAll()
  611. {
  612.  UBYTE         name[40],unit[10];
  613.  register long test;
  614.  
  615.  if(USModus==FALSE)
  616.   {
  617.    LocaleBase=OpenLibrary("locale.library",38L);
  618.    if(LocaleBase!=NULL)
  619.     {
  620.      Locale=OpenLocale(NULL);
  621.      if(Locale!=NULL)
  622.        Catalog=OpenCatalogA(Locale,"musicbox.catalog",NULL);
  623.     }
  624.   }
  625.  GfxBase=OpenLibrary("graphics.library",37L);
  626.  IntuitionBase=OpenLibrary("intuition.library",37L);
  627.  if((GfxBase==NULL)||(IntuitionBase==NULL))
  628.   {
  629.    puts(GS(1,"This program requires Kickstart 2.0, V37!"));
  630.    CloseAll();
  631.   }
  632.  MusicBoxBase=OpenLibrary("musicbox.library",0L);
  633.  if(MusicBoxBase==NULL)
  634.   {
  635.    Error(GS(55,"Unable to open musicbox.library!"));
  636.    CloseAll();
  637.   }
  638.  if((UnIconifyMusicBox())==0)
  639.    CloseAll();
  640.  if((LibVersionCheck(VERSION))==0)
  641.    CloseAll();
  642.  AmigaGuideBase=OpenLibrary("amigaguide.library",0L);
  643.  IconBase=OpenLibrary("icon.library",0L);
  644.  if(IconBase==NULL)
  645.   {
  646.    Error(GS(2,"Unable to open icon.library!"));
  647.    CloseAll();
  648.   }
  649.  WorkbenchBase=OpenLibrary("workbench.library",37L);
  650.  if(WorkbenchBase==NULL)
  651.   {
  652.    Error(GS(3,"Unable to open workbench.library!"));
  653.    CloseAll();
  654.   }
  655.  GadToolsBase=OpenLibrary("gadtools.library",37L);
  656.  if(GadToolsBase==NULL)
  657.   {
  658.    Error(GS(4,"Unable to open gadtools.library!"));
  659.    CloseAll();
  660.   }
  661.  DiskfontBase=OpenLibrary("diskfont.library",0L);
  662.  if(DiskfontBase==NULL)
  663.   {
  664.    Error(GS(4,"Unable to open diskfont.library!"));
  665.    CloseAll();
  666.   }
  667.  Forbid();
  668.  TimerBase=FindName(&SysBase->DeviceList,"timer.device");
  669.  if(TimerBase!=NULL) TimerBase->lib_OpenCnt++;
  670.  Permit();
  671.  Randomize();
  672.  if(TimerBase==NULL)
  673.   {
  674.    Error(GS(74,"Where is the timer.device?"));
  675.    CloseAll();
  676.   }
  677.  Katalog=AllocMem(sizeof(struct Katalog),MEMF_ANY);
  678.  if(Katalog==NULL)
  679.   {
  680.    Error(GS(6,"Not enough memory!"));
  681.    CloseAll();
  682.   }
  683.  
  684.  test=GetVar("CDROM_DEVICE",&name,38,0);
  685.  if(test==-1)
  686.   {
  687.    if(DeviceName[0]==0x00)
  688.     {
  689.      Error(GS(7,"Music Box requires the ENV-variable\n"
  690.            "CDROM_DEVICE\n"
  691.            "or the ToolTypes-entry\n"
  692.            "DEVICE=<name>\n"
  693.            "with the name of your SCSI-device!\n"
  694.            "You must create it before starting MusicBox!\n"
  695.            "Example: SetENV CDROM_DEVICE scsi.device"));
  696.      CloseAll();
  697.     }
  698.   }
  699.  else
  700.    strcpy(&DeviceName,&name);
  701.  
  702.  test=GetVar("CDROM_UNIT",&unit,8,0);
  703.  if(test==-1)
  704.   {
  705.    if(UnitNumber==-1)
  706.     {
  707.      Error(GS(8,"Music Box requires the ENV-variable\n"
  708.            "CDROM_UNIT\n"
  709.            "or the ToolTypes-entry\n"
  710.            "UNIT=<number>\n"
  711.            "with the unit number of your CD-ROM-drive!\n"
  712.            "You must create it before starting MusicBox!\n"
  713.            "Example: SetENV CDROM_UNIT 6"));
  714.      CloseAll();
  715.     }
  716.   }
  717.  else
  718.    UnitNumber=atol(&unit);
  719.  
  720.  test=InitSCSI(&DeviceName,UnitNumber);
  721.  if(test!=0)
  722.    CloseAll();
  723.  test=InitIcon();
  724.  if(test==FALSE) return;
  725.  DisplayFont=OpenDiskFont(&DisplayAttr);
  726.  if(DisplayFont==NULL)
  727.   {
  728.    Error(GS(9,"Unable to open font: hifi-display.font 18"));
  729.    CloseAll();
  730.   }
  731.  SmallFont=OpenDiskFont(&SmallAttr);
  732.  if(SmallFont==NULL)
  733.   {
  734.    Error(GS(10,"Unable to open font: hifi-display.font 7"));
  735.    CloseAll();
  736.   }
  737.  TimesFont=OpenDiskFont(&TimesAttr);
  738.  if(TimesFont==NULL)
  739.   {
  740.    Error(GS(11,"Unable to open font: times.font 18"));
  741.    CloseAll();
  742.   }
  743.  test=SetupScreen();
  744.  if(test!=0)
  745.    CloseAll();
  746.  AppPort=CreatePortA(0L,0L);
  747.  ControlPort=CreatePortA(MUSICBOX_HOSTNAME,0L);
  748.  ARexxPort=CreatePortA(&ARexxName,2L);
  749.  if((AppPort==NULL)||(ControlPort==NULL)||(ARexxPort==NULL))
  750.   {
  751.    Error(GS(12,"Unable to create message ports!"));
  752.    CloseAll();
  753.   }
  754.  ProcessSignal=AllocSignal(-1L);
  755.  if(ProcessSignal==-1L)
  756.   {
  757.    Error(GS(13,"Not enough free task signals!"));
  758.    CloseAll();
  759.   }
  760.  NewListA(&Liste);
  761.  test=InitProzess();
  762.  if(test)
  763.   {
  764.    Error(GS(14,"Unable to create process for display"));
  765.    CloseAll();
  766.   }
  767.  IsIconify=TRUE;
  768.  PrefsLaden();
  769.  IsIconify=FALSE;
  770.  
  771.  if(Einstellungen.AutoLoad)
  772.   {
  773.    if(LowRes==FALSE)
  774.      OpenArchive(0,0,OA_QUIET);
  775.    else
  776.      OpenArchive(0,0,OA_QUIET|OA_LOWRES);
  777.   }
  778.  
  779.  ProcessSignalMask=(1L<<ProcessSignal);
  780.  AppSignalMask=(1L<<AppPort->mp_SigBit);
  781.  ControlSignalMask=(1L<<ControlPort->mp_SigBit);
  782.  ARexxSignalMask=(1L<<ARexxPort->mp_SigBit);
  783.  
  784.  if(Quiet==FALSE)
  785.   {
  786.    test=OpenCDPlayerWindow();
  787.    if(test!=0)
  788.      CloseAll();
  789.   }
  790.  else
  791.   Iconify();
  792.  
  793.  RPort=CDPlayerWnd->RPort;
  794.  ox=OffsetX(CDPlayerWnd);
  795.  oy=OffsetY(CDPlayerWnd);
  796.  
  797.  IDCMPSignalMask=(1L<<CDPlayerWnd->UserPort->mp_SigBit);
  798.  WaitSignalMask=IDCMPSignalMask+ProcessSignalMask+ControlSignalMask+ARexxSignalMask;
  799.  
  800.  CDDisplay();
  801.  PrefsZeigen();
  802.  TesteLaufwerk();
  803. }
  804.  
  805.  
  806. void main(argc,argv)
  807.  long   argc;
  808.  UBYTE *argv[];
  809. {
  810.  REGISTER ULONG              Signale;
  811.  REGISTER int                test;
  812.  REGISTER UBYTE             *name;
  813.  register struct WBArg      *wb;
  814.  register struct DiskObject *di;
  815.  
  816.  if(argc>1)
  817.   {
  818.    if(!(strcmp(argv[1],"?")))
  819.     {
  820.      printf("USAGE: %s [-i|IGNORETOOLTYPES -q|QUIET -u|US\n",argv[0]);
  821.      puts("           -l|LOWRES -r|NOREQ -f|FASTEXIT]");
  822.      exit(0);
  823.     }
  824.    for(test=1;test<argc;test++)
  825.     {
  826.      if(!(strcmp(argv[test],"-q"))) Quiet=TRUE;
  827.      if(!(strcmp(argv[test],"QUIET"))) Quiet=TRUE;
  828.      if(!(strcmp(argv[test],"-u"))) USModus=TRUE;
  829.      if(!(strcmp(argv[test],"US"))) USModus=TRUE;
  830.      if(!(strcmp(argv[test],"-l"))) LowRes=TRUE;
  831.      if(!(strcmp(argv[test],"LOWRES"))) LowRes=TRUE;
  832.      if(!(strcmp(argv[test],"-r"))) NoReq=TRUE;
  833.      if(!(strcmp(argv[test],"NOREQ"))) NoReq=TRUE;
  834.      if(!(strcmp(argv[test],"-i"))) NoTT=TRUE;
  835.      if(!(strcmp(argv[test],"IGNORETOOLTYPES"))) NoTT=TRUE;
  836.      if(!(strcmp(argv[test],"-f"))) FastExit=TRUE;
  837.      if(!(strcmp(argv[test],"FASTEXIT"))) FastExit=TRUE;
  838.     }
  839.   }
  840.  
  841.  if(argc==0)
  842.   {
  843.    wb=WBenchMsg->sm_ArgList;
  844.    name=wb->wa_Name;
  845.   }
  846.  else
  847.    name=argv[0];
  848.  
  849.  DeviceName[0]=0x00;
  850.  sprintf(&ARexxName,"MusicBoxARexx");
  851.  if(NoTT==FALSE)
  852.   {
  853.    IconBase=OpenLibrary("icon.library",0L);
  854.    if(IconBase!=NULL)
  855.     {
  856.      di=GetDiskObject(name);
  857.      if(di!=NULL)
  858.       {
  859.        name=FindToolType(di->do_ToolTypes,"QUIET");
  860.        if(name) if((MatchToolValue(name,"ON"))) Quiet=TRUE;
  861.        name=FindToolType(di->do_ToolTypes,"FASTEXIT");
  862.        if(name) if((MatchToolValue(name,"ON"))) FastExit=TRUE;
  863.        name=FindToolType(di->do_ToolTypes,"US");
  864.        if(name) if((MatchToolValue(name,"ON"))) USModus=TRUE;
  865.        name=FindToolType(di->do_ToolTypes,"LOWRES");
  866.        if(name) if((MatchToolValue(name,"ON"))) LowRes=TRUE;
  867.        name=FindToolType(di->do_ToolTypes,"DEVICE");
  868.        if(name)
  869.         {
  870.          test=strlen(name); if(test>38) test=38;
  871.          CopyMem(name,&DeviceName,test);
  872.          DeviceName[39]=0x00;
  873.         }
  874.        name=FindToolType(di->do_ToolTypes,"AREXXPORT");
  875.        if(name)
  876.         {
  877.          test=strlen(name); if(test>38) test=38;
  878.          CopyMem(name,&ARexxName,test);
  879.          ARexxName[39]=0x00;
  880.         }
  881.        name=FindToolType(di->do_ToolTypes,"UNIT");
  882.        if(name) UnitNumber=atol(name);
  883.        FreeDiskObject(di);
  884.       }
  885.      CloseLibrary(IconBase);
  886.      IconBase=NULL;
  887.     }
  888.   }
  889.  
  890.  OpenAll();
  891.  
  892.  do
  893.   {
  894.    Signale=Wait(WaitSignalMask);
  895.    if(Signale & IDCMPSignalMask)
  896.      test=HandleCDPlayerIDCMP();
  897.    if(Signale & ProcessSignalMask)
  898.      IntuiTicks();
  899.    if(Signale & ControlSignalMask)
  900.      if((ControlHandler())==1) test=2;
  901.    if(Signale & ARexxSignalMask)
  902.      if((ARexxHandler())==1) test=2;
  903.  
  904.    if(test==2)
  905.     {
  906.      Iconify();
  907.      test=1;
  908.     }
  909.   } while(test==1);
  910.  
  911.  CloseAll();
  912. }
  913.  
  914. void ZeigeNum()
  915. {
  916.  struct TagItem tagr[3];
  917.  UBYTE          text[6];
  918.  
  919.  if(IsIconify) return;
  920.  
  921.  if(Einstellungen.NumS==1)
  922.   sprintf(&text,"%d_",Einstellungen.Num);
  923.  else if(Einstellungen.NumS==2)
  924.   sprintf(&text,"%02d",Einstellungen.Num);
  925.  else
  926.   strcpy(&text,"__");
  927.  
  928.  SetAPen(RPort,FARBE);
  929.  SetFont(RPort,Font);
  930.  if(LowRes==FALSE)
  931.    PutText(308,164,&text);
  932.  else
  933.   {
  934.    PutText(305,125,&text);
  935.    tagr[0].ti_Tag  = GT_VisualInfo;
  936.    tagr[0].ti_Data = VisualInfo;
  937.    tagr[1].ti_Tag  = GTBB_Recessed;
  938.    tagr[1].ti_Data = TRUE;
  939.    tagr[2].ti_Tag  = TAG_DONE;
  940.    DrawBevelBox2( CDPlayerWnd->RPort, ox + 296, oy + 152, 37, 19, &tagr);
  941.   }
  942.  SetFont(RPort,DisplayFont);
  943. }
  944.  
  945. void Num(n)
  946.  UBYTE n;
  947. {
  948.  REGISTER UBYTE a,b;
  949.  
  950.  if(IsIconify) return;
  951.  
  952.  SetAPen(RPort,FARBE);
  953.  SetFont(RPort,Font);
  954.  if((Einstellungen.CDEingelegt)&&(Einstellungen.CDTyp==AUDIO))
  955.   {
  956.    a=ThisCD->Anzahl / 10;
  957.    b=ThisCD->Anzahl % 10;
  958.    if(Einstellungen.NumS!=1)
  959.     {
  960.      Einstellungen.Num=n;
  961.      if(n>a)
  962.       {
  963.        Einstellungen.NumS=2;
  964.        if(Einstellungen.Num<1) Einstellungen.Num=1;
  965.        if(Einstellungen.Num<1) Einstellungen.Num=1;
  966.        if(Einstellungen.Num>ThisCD->Anzahl) Einstellungen.Num=ThisCD->Anzahl;
  967.       }
  968.      else Einstellungen.NumS=1;
  969.     }
  970.    else
  971.     {
  972.      Einstellungen.Num=Einstellungen.Num*10+n;
  973.      Einstellungen.NumS=2;
  974.      if(Einstellungen.Num<1) Einstellungen.Num=1;
  975.      if(Einstellungen.Num>ThisCD->Anzahl) Einstellungen.Num=ThisCD->Anzahl;
  976.     }
  977.   }
  978.  else
  979.    Einstellungen.NumS=0;
  980.  ZeigeNum();
  981. }
  982.  
  983. void T0Clicked(){ Num(0); }
  984. void T1Clicked(){ Num(1); }
  985. void T2Clicked(){ Num(2); }
  986. void T3Clicked(){ Num(3); }
  987. void T4Clicked(){ Num(4); }
  988. void T5Clicked(){ Num(5); }
  989. void T6Clicked(){ Num(6); }
  990. void T7Clicked(){ Num(7); }
  991. void T8Clicked(){ Num(8); }
  992. void T9Clicked(){ Num(9); }
  993.  
  994. void TSternClicked()
  995. {
  996.  if((Einstellungen.CDEingelegt)&&(Einstellungen.CDTyp==AUDIO))
  997.   {
  998.    if(Einstellungen.NumS!=0)
  999.     {
  1000.      if(Einstellungen.Track!=Einstellungen.Num)
  1001.       {
  1002.        if(Einstellungen.Track>Einstellungen.Num)
  1003.          Symbol(MINUS);
  1004.        else
  1005.          Symbol(PLUS);
  1006.        Einstellungen.Track=Einstellungen.Num;
  1007.        Einstellungen.Funktion=STOP;
  1008.        Wiedergabe();
  1009.        Einstellungen.Funktion=WIEDERGABE;
  1010.        Einstellungen.NumS=0;
  1011.        ZeigeNum();
  1012.        ZeigeTrackDisplay();
  1013.       }
  1014.     }
  1015.   }
  1016. }
  1017.  
  1018. void TClearClicked()
  1019. {
  1020.  Einstellungen.NumS=0;
  1021.  ZeigeNum();
  1022. }
  1023.  
  1024. void TNumberClicked()
  1025. {
  1026.  register int i;
  1027.  
  1028.  if(Einstellungen.Funktion!=STANDBY)
  1029.   {
  1030.    Randomize();
  1031.    i=Random(ThisCD->Anzahl);
  1032.    if(i>Einstellungen.Track) Symbol(PLUS); else Symbol(MINUS);
  1033.    Einstellungen.Funktion=STOP;
  1034.    Einstellungen.Track=i;
  1035.    Wiedergabe();
  1036.    Einstellungen.Funktion=WIEDERGABE;
  1037.    ZeigeTrackDisplay();
  1038.   }
  1039. }
  1040.  
  1041. void ListeClicked(dummy,code)
  1042.  BOOL  dummy;
  1043.  UWORD code;
  1044. {
  1045.  register struct StringInfo *si;
  1046.  
  1047.  if(code!=Einstellungen.Auswahl)
  1048.   {
  1049.    si=CDPlayerGadgets[24]->SpecialInfo;
  1050.    if(code==0)
  1051.      strcpy(si->Buffer,&Katalog->CDName);
  1052.    else
  1053.      strcpy(si->Buffer,&Katalog->KE[code-1].Titel);
  1054.    RefreshGList(CDPlayerGadgets[24],CDPlayerWnd,NULL,1L);
  1055.  
  1056.    Einstellungen.Auswahl=code;
  1057.   }
  1058.  else
  1059.   {
  1060.    if(code!=0)
  1061.     {
  1062.      Einstellungen.Funktion=STOP;
  1063.      Einstellungen.Track=code;
  1064.      Wiedergabe();
  1065.     }
  1066.   }
  1067. }
  1068.  
  1069. void AuswahlmodusClicked(dummy,code)
  1070.  BOOL  dummy;
  1071.  UWORD code;
  1072. {
  1073.  Einstellungen.Auswahlmodus=code;
  1074.  Randomize();
  1075. }
  1076.  
  1077. void StopClicked()
  1078. {
  1079.  if((Einstellungen.Funktion==AUTO)||(Einstellungen.Funktion==WIEDERGABE)||(Einstellungen.Funktion==PAUSE)||(Einstellungen.Funktion==RUECKLAUF)||(Einstellungen.Funktion==VORLAUF))
  1080.   {
  1081.    Symbol(STOP);
  1082.    Stop();
  1083.    Einstellungen.Funktion=STOP;
  1084.    ZeigeStatus();
  1085.   }
  1086. }
  1087.  
  1088. void WiedergabeClicked()
  1089. {
  1090.  if(!(Einstellungen.Funktion==STANDBY))
  1091.   {
  1092.    if(Einstellungen.Funktion==WIEDERGABE)
  1093.     {
  1094.      Symbol(PAUSE);
  1095.      Pause();
  1096.      Einstellungen.Funktion=PAUSE;
  1097.     }
  1098.    else
  1099.     {
  1100.      Symbol(WIEDERGABE);
  1101.      Wiedergabe();
  1102.      Einstellungen.Funktion=WIEDERGABE;
  1103.     }
  1104.    ZeigeStatus();
  1105.   }
  1106. }
  1107.  
  1108. void RuecklaufClicked()
  1109. {
  1110.  if(!(Einstellungen.Funktion==STANDBY))
  1111.   {
  1112.    Einstellungen.Funktion=RUECKLAUF;
  1113.    Pause();
  1114.    ZeigeStatus();
  1115.   }
  1116. }
  1117.  
  1118. void VorlaufClicked()
  1119. {
  1120.  if(!(Einstellungen.Funktion==STANDBY))
  1121.   {
  1122.    Einstellungen.Funktion=VORLAUF;
  1123.    Pause();
  1124.    ZeigeStatus();
  1125.   }
  1126. }
  1127.  
  1128. void MinusClicked()
  1129. {
  1130.  if(!(Einstellungen.Funktion==STANDBY))
  1131.   {
  1132.    if(Einstellungen.Track>1)
  1133.     {
  1134.      Symbol(MINUS);
  1135.      Einstellungen.Funktion=MINUS;
  1136.      Einstellungen.Track--;
  1137.      Wiedergabe();
  1138.      Einstellungen.Funktion=WIEDERGABE;
  1139.      ZeigeTrackDisplay();
  1140.     }
  1141.   }
  1142. }
  1143.  
  1144. void PlusClicked()
  1145. {
  1146.  if(!(Einstellungen.Funktion==STANDBY))
  1147.   {
  1148.    if(Einstellungen.Track<ThisCD->Anzahl)
  1149.     {
  1150.      Symbol(PLUS);
  1151.      Einstellungen.Funktion=PLUS;
  1152.      Einstellungen.Track++;
  1153.      Wiedergabe();
  1154.      Einstellungen.Funktion=WIEDERGABE;
  1155.      ZeigeTrackDisplay();
  1156.     }
  1157.   }
  1158. }
  1159.  
  1160. void AuswurfClicked()
  1161. {
  1162.  if(!(Einstellungen.Lock))
  1163.   {
  1164.    Symbol(STANDBY);
  1165.    Auswurf();
  1166.    Einstellungen.Funktion=STANDBY;
  1167.    ZeigeStatus();
  1168.    ZeigeCDInfo();
  1169.   }
  1170. }
  1171.  
  1172. void LockClicked()
  1173. {
  1174.  if(Einstellungen.Lock) Einstellungen.Lock=0; else Einstellungen.Lock=1;
  1175.  AuswurfLock();
  1176.  ZeigeCDInfo();
  1177. }
  1178.  
  1179. void PositionClicked(gadgetUp,code)
  1180.  BOOL  gadgetUp;
  1181.  UWORD code;
  1182. {
  1183.  REGISTER ULONG c;
  1184.  
  1185.  if(DivLevel==TRUE) c=code+code; else c=code;
  1186.  if(Einstellungen.Funktion!=STANDBY)
  1187.   {
  1188.    if(gadgetUp==FALSE)
  1189.     {
  1190.      Einstellungen.Funktion=POSITION;
  1191.      Einstellungen.Adresse=ThisCD->Track[Einstellungen.Track-1].SAdresse+c;
  1192.      ZeigeTrackDisplay();
  1193.     }
  1194.    else
  1195.     {
  1196.      Einstellungen.Funktion=PAUSE;
  1197.      Einstellungen.Adresse=ThisCD->Track[Einstellungen.Track-1].SAdresse+c;
  1198.      Continue();
  1199.      Einstellungen.Funktion=WIEDERGABE;
  1200.      ZeigeTrackDisplay();
  1201.     }
  1202.   }
  1203. }
  1204.  
  1205. void VolumeLClicked(dummy,code)
  1206.  BOOL  dummy;
  1207.  UWORD code;
  1208. {
  1209.  struct TagItem tag[2];
  1210.  
  1211.  Einstellungen.VolumenL=code;
  1212.  if(Einstellungen.Kopplung)
  1213.   {
  1214.    Einstellungen.VolumenR=Einstellungen.VolumenL;
  1215.    tag[0].ti_Tag=GTSL_Level;
  1216.    tag[0].ti_Data=Einstellungen.VolumenR;
  1217.    tag[1].ti_Tag=TAG_DONE;
  1218.    GTSetGadgetAttrsA(CDPlayerGadgets[25],CDPlayerWnd,NULL,&tag);
  1219.   }
  1220.  Volumen();
  1221.  ZeigeVolumen();
  1222. }
  1223.  
  1224. void VolumeRClicked(dummy,code)
  1225.  BOOL  dummy;
  1226.  UWORD code;
  1227. {
  1228.  struct TagItem tag[2];
  1229.  
  1230.  Einstellungen.VolumenR=code;
  1231.  if(Einstellungen.Kopplung)
  1232.   {
  1233.    Einstellungen.VolumenL=Einstellungen.VolumenR;
  1234.    tag[0].ti_Tag=GTSL_Level;
  1235.    tag[0].ti_Data=Einstellungen.VolumenL;
  1236.    tag[1].ti_Tag=TAG_DONE;
  1237.    GTSetGadgetAttrsA(CDPlayerGadgets[23],CDPlayerWnd,NULL,&tag);
  1238.   }
  1239.  Volumen();
  1240.  ZeigeVolumen();
  1241. }
  1242.  
  1243. void AudioLClicked(dummy,code)
  1244.  BOOL  dummy;
  1245.  UWORD code;
  1246. {
  1247.  struct TagItem tag[2];
  1248.  
  1249.  switch(code)
  1250.   {
  1251.    case 0:
  1252.      Einstellungen.AudioL=AUDIO_LINKS;
  1253.     break;
  1254.    case 1:
  1255.      Einstellungen.AudioL=AUDIO_RECHTS;
  1256.     break;
  1257.    case 2:
  1258.      Einstellungen.AudioL=AUDIO_BEIDE;
  1259.     break;
  1260.    case 3:
  1261.      Einstellungen.AudioL=AUDIO_AUS;
  1262.     break;
  1263.   }
  1264.  
  1265.  tag[0].ti_Tag=GTCY_Active;
  1266.  tag[0].ti_Data=code;
  1267.  tag[1].ti_Tag=TAG_DONE;
  1268.  GTSetGadgetAttrsA(CDPlayerGadgets[21],CDPlayerWnd,NULL,&tag);
  1269.  
  1270.  ZeigeLR();
  1271. }
  1272.  
  1273. void AudioRClicked(dummy,code)
  1274.  BOOL  dummy;
  1275.  UWORD code;
  1276. {
  1277.  struct TagItem tag[2];
  1278.  
  1279.  switch(code)
  1280.   {
  1281.    case 1:
  1282.      Einstellungen.AudioR=AUDIO_LINKS;
  1283.     break;
  1284.    case 0:
  1285.      Einstellungen.AudioR=AUDIO_RECHTS;
  1286.     break;
  1287.    case 2:
  1288.      Einstellungen.AudioR=AUDIO_BEIDE;
  1289.     break;
  1290.    case 3:
  1291.      Einstellungen.AudioR=AUDIO_AUS;
  1292.     break;
  1293.   }
  1294.  
  1295.  tag[0].ti_Tag=GTCY_Active;
  1296.  tag[0].ti_Data=code;
  1297.  tag[1].ti_Tag=TAG_DONE;
  1298.  GTSetGadgetAttrsA(CDPlayerGadgets[22],CDPlayerWnd,NULL,&tag);
  1299.  
  1300.  ZeigeLR();
  1301. }
  1302.  
  1303. void TitelClicked()
  1304. {
  1305.  struct TagItem              tag[2];
  1306.  register struct StringInfo *si;
  1307.  
  1308.  if(Einstellungen.CDEingelegt)
  1309.   {
  1310.    if(Einstellungen.Auswahl!=255)
  1311.     {
  1312.      si=CDPlayerGadgets[24]->SpecialInfo;
  1313.      if(Einstellungen.Auswahl==0)
  1314.        strcpy(&Katalog->CDName,si->Buffer);
  1315.      else
  1316.        strcpy(&Katalog->KE[Einstellungen.Auswahl-1].Titel,si->Buffer);
  1317.  
  1318.      strcpy(si->Buffer,"");
  1319.      RefreshGList(CDPlayerGadgets[24],CDPlayerWnd,NULL,1L);
  1320.      Einstellungen.CatChange=1;
  1321.      ListeErstellen(FALSE);
  1322.      ZeigeTrackDisplay();
  1323.     }
  1324.   }
  1325. }
  1326.  
  1327. void AutoRepeat(item)
  1328.  struct MenuItem *item;
  1329. {
  1330.  if(item->Flags & CHECKED)
  1331.    Einstellungen.AutoRepeat=1;
  1332.  else
  1333.    Einstellungen.AutoRepeat=0;
  1334.  ZeigeCDInfo();
  1335. }
  1336.  
  1337. void AutoStart(item)
  1338.  struct MenuItem *item;
  1339. {
  1340.  if(item->Flags & CHECKED)
  1341.    Einstellungen.AutoStart=1;
  1342.  else
  1343.    Einstellungen.AutoStart=0;
  1344.  ZeigeCDInfo();
  1345. }
  1346.  
  1347. void AutoSave(item)
  1348.  struct MenuItem *item;
  1349. {
  1350.  if(item->Flags & CHECKED)
  1351.    Einstellungen.AutoSave=1;
  1352.  else
  1353.    Einstellungen.AutoSave=0;
  1354. }
  1355.  
  1356. void AutoLoad(item)
  1357.  struct MenuItem *item;
  1358. {
  1359.  if(item->Flags & CHECKED)
  1360.    Einstellungen.AutoLoad=1;
  1361.  else
  1362.    Einstellungen.AutoLoad=0;
  1363. }
  1364.  
  1365. void AutoFlush(item)
  1366.  struct MenuItem *item;
  1367. {
  1368.  if(item->Flags & CHECKED)
  1369.    Einstellungen.AutoFlush=1;
  1370.  else
  1371.    Einstellungen.AutoFlush=0;
  1372. }
  1373.  
  1374. void Zeit1(item)
  1375.  struct MenuItem *item;
  1376. {
  1377.  item->Flags |= CHECKED;
  1378.  Einstellungen.Anzeige=TRACK_ANFANG;
  1379.  TesteLaufwerk();
  1380. }
  1381.  
  1382. void Zeit2(item)
  1383.  struct MenuItem *item;
  1384. {
  1385.  item->Flags |= CHECKED;
  1386.  Einstellungen.Anzeige=CD_ANFANG;
  1387.  TesteLaufwerk();
  1388. }
  1389.  
  1390. void Zeit3(item)
  1391.  struct MenuItem *item;
  1392. {
  1393.  item->Flags |= CHECKED;
  1394.  Einstellungen.Anzeige=TRACK_ENDE;
  1395.  TesteLaufwerk();
  1396. }
  1397.  
  1398. void Zeit4(item)
  1399.  struct MenuItem *item;
  1400. {
  1401.  item->Flags |= CHECKED;
  1402.  Einstellungen.Anzeige=CD_ENDE;
  1403.  TesteLaufwerk();
  1404. }
  1405.  
  1406. void Format1(item)
  1407.  struct MenuItem *item;
  1408. {
  1409.  item->Flags |= CHECKED;
  1410.  Einstellungen.Format=ZEIT;
  1411.  TesteLaufwerk();
  1412. }
  1413.  
  1414. void Format2(item)
  1415.  struct MenuItem *item;
  1416. {
  1417.  item->Flags |= CHECKED;
  1418.  Einstellungen.Format=ADRESSE;
  1419.  TesteLaufwerk();
  1420. }
  1421.  
  1422. void Format3(item)
  1423.  struct MenuItem *item;
  1424. {
  1425.  item->Flags |= CHECKED;
  1426.  Einstellungen.Format=PROZENT;
  1427.  TesteLaufwerk();
  1428. }
  1429.  
  1430. void Format4(item)
  1431.  struct MenuItem *item;
  1432. {
  1433.  item->Flags |= CHECKED;
  1434.  Einstellungen.Format=MEGABYTES;
  1435.  TesteLaufwerk();
  1436. }
  1437.  
  1438. void JoystickA(item)
  1439.  struct MenuItem *item;
  1440. {
  1441.  item->Flags |= CHECKED;
  1442.  Einstellungen.Kontrolle=AUS;
  1443.  ZeigeStatus();
  1444. }
  1445.  
  1446. void Joystick1(item)
  1447.  struct MenuItem *item;
  1448. {
  1449.  item->Flags |= CHECKED;
  1450.  Einstellungen.Kontrolle=JOYSTICK_I;
  1451.  ZeigeStatus();
  1452. }
  1453.  
  1454. void Joystick2(item)
  1455.  struct MenuItem *item;
  1456. {
  1457.  item->Flags |= CHECKED;
  1458.  Einstellungen.Kontrolle=JOYSTICK_II;
  1459.  ZeigeStatus();
  1460. }
  1461.  
  1462. void Hilfe()
  1463. {
  1464.  register struct NewAmigaGuide *amg;
  1465.  struct FileLock               *lock;
  1466.  APTR                           ctx;
  1467.  UBYTE                          name[200];
  1468.  
  1469.  if(AmigaGuideBase!=NULL)
  1470.   {
  1471.    amg=AllocMem(sizeof(struct NewAmigaGuide),MEMF_CLEAR|MEMF_ANY);
  1472.    if(amg!=NULL)
  1473.     {
  1474.      amg->nag_Name="MusicBox:MusicBox.guide";
  1475.      SleepPointer(CDPlayerWnd);
  1476.      lock=NULL;
  1477.  
  1478.      if(Locale)
  1479.       {
  1480.        sprintf(&name,"MusicBox:%s/MusicBox.guide",Locale->loc_LanguageName);
  1481.        lock=Lock(&name,ACCESS_READ);
  1482.        if(lock!=NULL)
  1483.         {
  1484.          UnLock(lock);
  1485.          amg->nag_Name=&name;
  1486.         }
  1487.       }
  1488.  
  1489.      ctx=OpenAmigaGuide(amg,NULL);
  1490.      if(ctx!=NULL)
  1491.        CloseAmigaGuide(ctx);
  1492.      else
  1493.        Error(GS(79,"AmigaGuide is unable to load guide file!"));
  1494.  
  1495.      ClearPointer(CDPlayerWnd);
  1496.      FreeMem(amg,sizeof(struct NewAmigaGuide));
  1497.     }
  1498.    else
  1499.      Error(GS(6,"Not enough memory!"));
  1500.   }
  1501.  else
  1502.    Error(GS(78,"AmigaGuide is not available!"));
  1503. }
  1504.  
  1505. void KopplungPressed()
  1506. {
  1507.  REGISTER BOOL  bool;
  1508.  struct TagItem tag[2];
  1509.  
  1510.  if(Einstellungen.Kopplung)
  1511.    { Einstellungen.Kopplung=0; bool=FALSE; }
  1512.  else
  1513.    { Einstellungen.Kopplung=1; bool=TRUE;  }
  1514.  
  1515.  tag[0].ti_Tag=GTCB_Checked;
  1516.  tag[0].ti_Data=bool;
  1517.  tag[1].ti_Tag=TAG_DONE;
  1518.  GTSetGadgetAttrsA(CDPlayerGadgets[26],CDPlayerWnd,NULL,&tag);
  1519. }
  1520.  
  1521. void KopplungClicked(gadgetUp)
  1522.  BOOL gadgetUp;
  1523. {
  1524.  if(gadgetUp)
  1525.   {
  1526.    if(CDPlayerGadgets[26]->Flags & SELECTED)
  1527.      Einstellungen.Kopplung=1;
  1528.    else
  1529.      Einstellungen.Kopplung=0;
  1530.   }
  1531. }
  1532.  
  1533. void TesteLaufwerk()
  1534. {
  1535.  ZeigeStatus();
  1536.  ZeigeCDInfo();
  1537.  if(IsIconify) LeseStatus();
  1538.  if(Einstellungen.AutoCnt>0)
  1539.   {
  1540.    Einstellungen.AutoCnt++;
  1541.    if(Einstellungen.AutoCnt>5)
  1542.     {
  1543.      Einstellungen.AutoCnt=0;
  1544.      if(Einstellungen.Funktion==AUTO)
  1545.       {
  1546.        if(Einstellungen.Auswahlmodus==LISTE)
  1547.          Einstellungen.Track=1;
  1548.        else
  1549.          Einstellungen.Track=Random(ThisCD->Anzahl);
  1550.        Symbol(WIEDERGABE);
  1551.        WiedergabeClicked();
  1552.        Einstellungen.Funktion=WIEDERGABE;
  1553.       }
  1554.     }
  1555.   }
  1556. }
  1557.  
  1558. void IntuiTicks()
  1559. {
  1560.  if(Einstellungen.Kontrolle) JoystickHandler();
  1561.  Einstellungen.IntuiTicks++;
  1562.  if(Einstellungen.IntuiTicks>Einstellungen.TickCnt)
  1563.   {
  1564.    Einstellungen.IntuiTicks=0;
  1565.    TesteLaufwerk();
  1566.   }
  1567. }
  1568.  
  1569. void Iconify()
  1570. {
  1571.  BOOL  ende;
  1572.  ULONG Signale;
  1573.  int   test;
  1574.  
  1575.  AppItem=AddAppMenuItemA(0L,0L,"Music Box",AppPort,NULL);
  1576.  if(AppItem!=NULL)
  1577.   {
  1578.    AppIcon=AddAppIconA(1L,0L,"Music Box",AppPort,0L,&CDMusicBox,0L);
  1579.    if(AppIcon!=NULL)
  1580.     {
  1581.      CloseCDPlayerWindow();
  1582.      IsIconify=TRUE;
  1583.  
  1584.      WaitSignalMask=AppSignalMask+ProcessSignalMask+ControlSignalMask+ARexxSignalMask;
  1585.      ende=FALSE;
  1586.      SichereKatalog();
  1587.  
  1588.      while(ende==FALSE)
  1589.       {
  1590.        Signale=Wait(WaitSignalMask);
  1591.        if(Signale & AppSignalMask)
  1592.         {
  1593.          AppMsg=GetMsg(AppPort);
  1594.          if(AppMsg!=NULL)
  1595.           {
  1596.            ende=TRUE;
  1597.            ReplyMsg(AppMsg);
  1598.           }
  1599.         }
  1600.        if(Signale & ProcessSignalMask)
  1601.          IntuiTicks();
  1602.        if(Signale & ControlSignalMask)
  1603.          if((ControlHandler())==2) ende=TRUE;
  1604.        if(Signale & ARexxSignalMask)
  1605.          if((ARexxHandler())==2) ende=TRUE;
  1606.       }
  1607.  
  1608.      test=OpenCDPlayerWindow();
  1609.      if(test!=0)
  1610.       {
  1611.        RemoveAppIcon(AppIcon);
  1612.        RemoveAppMenuItem(AppItem);
  1613.        CloseAll();
  1614.       }
  1615.  
  1616.      RPort=CDPlayerWnd->RPort;
  1617.      ox=OffsetX(CDPlayerWnd);
  1618.      oy=OffsetY(CDPlayerWnd);
  1619.  
  1620.      IDCMPSignalMask=(1L<<CDPlayerWnd->UserPort->mp_SigBit);
  1621.      WaitSignalMask=IDCMPSignalMask+ProcessSignalMask+ControlSignalMask+ARexxSignalMask;
  1622.  
  1623.      Einstellungen.Titel=255;
  1624.      Einstellungen.Auswahl=255;
  1625.  
  1626.      PrefsZeigen();
  1627.  
  1628.      WarteAufAudio=FALSE;
  1629.      IstDatenCD=FALSE;
  1630.      IsIconify=FALSE;
  1631.      RemoveAppIcon(AppIcon);
  1632.     }
  1633.    RemoveAppMenuItem(AppItem);
  1634.    CDDisplay();
  1635.    TesteLaufwerk();
  1636.    CleanUpPort(AppPort);
  1637.   }
  1638. }
  1639.  
  1640.